﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for ManufarturerDAL
/// </summary>
public class ManufarturerDAL
{
    DataAccess db;
	public ManufarturerDAL()
	{
        db = new DataAccess();
    }
    public int InsertUpdateManufacturer(Manufacturer manu) 
    {
        SqlParameter[] paraList = new SqlParameter[3];
        paraList[0] = db.AddParameter("manufacturer_id", manu.Manufacturer_id, SqlDbType.Int);
        paraList[1] = db.AddParameter("name", manu.Name, SqlDbType.NVarChar);
        paraList[2] = db.AddParameter("image", manu.Image, SqlDbType.VarChar);
        return db.executeUpdate("IS_Manufacturer", paraList);
    }
    public DataTable getAllManufacturer()
    {
        return db.executeSelect("Select_Manufacturer");
    }
    public DataTable getManufacturerByID(int manufacturer_id)
    {
        SqlParameter[] paraList = new SqlParameter[3];
        paraList[0] = db.AddParameter("manufacturer", manufacturer_id, SqlDbType.Int);
        return db.executeSelect("Select_Manufacturer", paraList);
    }
    public DataTable getManufacturerByName(string name) 
    {
        SqlParameter[] paraList = new SqlParameter[3];
        paraList[1] = db.AddParameter("name", name, SqlDbType.NVarChar, 32);
        return db.executeSelect("Select_Manufacturer", paraList);
    }

    public int DeleteManuFactureDAL(Manufacturer manu){
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = db.AddParameter("manufacturer_id", manu.Manufacturer_id, SqlDbType.Int);
        return db.executeUpdate("sp_DeleteManuFac",paramList);
    }
}